package com.CMS.shared;

import java.util.ArrayList;
import java.util.List;

public class CompositeItem extends AbstractItem{
	
	private List<AbstractItem> lista = new ArrayList<AbstractItem>();
	private String m = "";

	@Override
	public String generate() {		
		m += "<li><a href=\"#\">"+descripcion+" +</a>";
		for(int i=0; i<lista.size(); i++){
			m += "<ul>"+ lista.get(i).generate()+"</ul>";
		}
		m += "</li>";
		return m;
	}
	
	public void addItem(AbstractItem item){
		lista.add(item);
	}

	@Override
	public boolean contains(long id) {
		boolean ban = false;
		if( this.id == id)
			return true;
		else
		{			
			for(int i=0; i<lista.size(); i++){
				if(lista.get(i).contains(id))
					ban = true;
			}				
		}
		return ban;
	}
}
